﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.ComponentModel
Public Class Idiomas
    Inherits BDDatos
    Sub New()
        Me.Tabla = "IDIOMAS_EST"
        Me.Vista = "VIDIOMAS_EST"
        Me.VistaDB = "IDIOMAS"
    End Sub
    Public HABLA As String
    Public LEE As String
    Public ESCRIBE As String
    Public COD_IDIOMA As String
    Public IDPK As String
    Public Function Insert() As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Insert into IDIOMAS_EST(Cedula,Cod_Idioma,Lee, Habla, Escribe)" & _
            "Values(:Cedula, :Cod_Idioma,:Lee, :Habla, :Escribe)"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.AsignarParametroCadena(":Cod_Idioma", Me.COD_IDIOMA)
            Me.AsignarParametroCadena(":Lee", LEE)
            Me.AsignarParametroCadena(":Habla", Me.Habla)
            Me.AsignarParametroCadena(":Escribe", Me.ESCRIBE)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
    Public Function Update() As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Update IDIOMAS_EST set Habla=:Habla, Lee=:Lee, Escribe=:Escribe Where Cedula=:Cedula And Cod_Idioma=:Cod_Idioma"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Habla", Me.Habla)
            Me.AsignarParametroCadena(":Lee", Lee)
            Me.AsignarParametroCadena(":Escribe", Me.Escribe)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.AsignarParametroCadena(":Cod_Idioma", Me.IDPK)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetxEgresado() As DataTable
        Me.Conectar()
        Me.querystring = "Select * from VIDIOMAS_EST where cedula=:cedula"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Me.usuario)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetxEgresado(ByVal Cedula As String) As DataTable
        Me.Conectar()
        Me.querystring = "Select * from VIDIOMAS_EST where cedula=:cedula"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Cedula)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetbyPK(ByVal Cod_Idioma As String) As DataTable
        Me.Conectar()
        Me.querystring = "Select * from IDIOMAS_EST where cedula=:cedula and Cod_Idioma=:Cod_Idioma"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Me.usuario)
        Me.AsignarParametroCadena(":Cod_Idioma", Cod_Idioma)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    Public Function Delete(ByVal Cod_Idioma As String) As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Delete from IDIOMAS_EST where Cod_Idioma=:Cod_Idioma and Cedula=:Cedula"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Cod_Idioma", Cod_Idioma)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
End Class
